package com.example.administrator.funchat.db;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;

/**
 * Created by Administrator on 2016/7/3.
 */
public class MyselfDatabaseHelper extends SQLiteOpenHelper {

    //建表语句,表名为Myself
    public static final String CREATE_MYSELF = "create table Myself("
            + "id integer primary key autoincrement,"
            + "nickname text,"
            + "mood text,"
            + "sex text,"
            + "headImage blob,"
            + "bgImage blob,"
            + "erweimaImage blob,"
            + "xiaoshiCode text,"
            + "address text)";

    private FragmentActivity mContext;

    //构造方法
    public MyselfDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        mContext = (FragmentActivity) context;
    }


    //建表
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {

        sqLiteDatabase.execSQL(CREATE_MYSELF);
        ContentValues values = new ContentValues();
        values.put("nickname", "请填写您的用户名");
        values.put("mood", "增加点心情");
        values.put("sex", "您随意");
        values.put("address", "哪里不好点哪里");
        sqLiteDatabase.insert("Myself", null, values);
        Toast.makeText(mContext, "建表成功", Toast.LENGTH_SHORT).show();
    }


    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }


}
